package com.csw.fish;

import java.awt.*;
import java.util.Random;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2022/11/15 13:47
 */
public class Enamy {

    //定义图片
    Image image;
    //定义物体坐标
    int x;
    int y;
    int width;
    int height;
    //移动速度
    int speed;
    //方向左向右1,右向左-1
    int dir = 1;
    //类型
    int type;
    //分值
    int count;

    //绘制自身方法
    public void panitSelf(Graphics g) {
        g.drawImage(image, x, y, width, height, null);
    }

    //获取自身矩形用于碰撞检测
    public Rectangle getRec() {
        return new Rectangle(x, y, width, height);
    }
}

class Enamy_1_L extends Enamy {
    Enamy_1_L() {
        this.x = -45;
        this.y = (int) (Math.random() * 700 + 100);
        this.width = 45;
        this.height = 69;
        this.speed = 10;
        this.count = 1;
        this.type = 1;
        this.image = GameUtils.enamy1_img;
    }
}
class Enamy_1_R extends Enamy_1_L{
    Enamy_1_R(){
        this.x=1400;
        dir=-1;
        this.image=GameUtils.enamyr_img;
    }
}
class Enamy_2_L extends Enamy{
    Enamy_2_L(){
        this.x = -100;
        this.y = (int) (Math.random() * 700 + 100);
        this.width = 100;
        this.height = 100;
        this.speed = 5;
        this.count = 2;
        this.type = 2;
        this.image = GameUtils.enamyl_2img;
    }
}
class Enamy_2_R extends Enamy_2_L{
    Enamy_2_R(){
        this.x=1400;
        dir=-1;
        this.image=GameUtils.enamyr_2img;
    }
}

class Enamy_3_L extends Enamy{
    Enamy_3_L(){
        this.x = -300;
        this.y = (int) (Math.random() * 700 + 100);
        this.width = 300;
        this.height = 150;
        this.speed = 15;
        this.type = 3;
        this.image = GameUtils.enamyl_3img;
    }

    @Override
    public Rectangle getRec() {
        return new Rectangle(x+40, y+30, width-80, height-60);
    }
}

class Enamy_3_R extends Enamy_3_L{
    Enamy_3_R(){
        this.x=1400;
        this.dir=-1;
        this.image=GameUtils.enamyr_3img;
    }
}

class Enamy_Boss extends Enamy{
    Enamy_Boss(){
        this.x=-1000;
        this.y= (int) (Math.random()*700+100);
        this.width=340;
        this.height=340;
        this.speed=100;
        this.count=10;
        this.type=10;
        this.image=GameUtils.enamy_bossimg;
    }
}